<!--
 @description 购物车备注
 @fileName index.vue
 @author zengqiongying
 @created 2022/08/02 09:19:38
-->
<template>
  <Popup
    v-model="popShow"
    position="bottom"
    :title="title"
    :show-cancel-button="false"
    @confirm="handleSubmit"
  >
    <div class="remark-content">
      <van-field
        v-model="content"
        type="textarea"
        row="5"
        label=""
        placeholder="请输入"
        :maxlength="maxlength"
        show-word-limit
      />
    </div>
  </Popup>
</template>

<script>
import Popup from '@/components/Popup'
export default {
  name: 'PopField',
  components: { Popup },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: ''
    },
    value: {
      type: String,
      default: ''
    },
    maxlength: {
      type: Number,
      default: 200
    }
  },
  data() {
    return {
      content: ''
    }
  },

  computed: {
    popShow: {
      set(val) {
        this.$emit('update:show', val)
      },
      get(val) {
        return this.show
      }
    }
  },
  watch: {
    value(val) {
      this.content = val
    }
  },
  created() {
    this.content = this.value || ''
  },
  methods: {
    handleSubmit() {
      const content = this.content.trim()
      this.$emit('input', content)
      this.popShow = false
    }
  }
}

</script>
<style lang='less' scoped>
.remark-content{
  padding: 20px 12px 10px;
  border-radius: 12px;
  border: 2px solid #EFF2F7;
  box-sizing: border-box;
  margin-bottom: 16px;
  .van-cell{
    padding: 0;
    font-size: 14px;
    color: #3C4458;
    line-height: 20px;
  }
}
</style>
